from time import sleep

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

from workchat.basetool.basetool import BaseTool



class ContactPage(BaseTool):
    def click_add_number(self):
        from workchat.workchat_po.add_number_page import AddNumberPage
        sleep(5)
        elem = self.driver.find_element(By.CSS_SELECTOR, "#js_contacts12 > div > div.member_colRight > div > div.js_party_info > div.js_has_member > div:nth-child(1) > a.qui_btn.ww_btn.js_add_member")
        def check(x):
            return elem.is_enabled()
        WebDriverWait(self.driver, 5).until(check)
        elem.click()
        return AddNumberPage()
    def return_number_list(self):
       name_list = []
       # finds_elements函数返回值为一个列表。
       sleep(3)
       eles = self.driver.find_elements(By.CSS_SELECTOR,".member_colRight_memberTable_td:nth-child(2)")
       for value in eles:
           name_list.append(value.get_attribute("title"))
       return name_list
